<template>
	<view class="padding-30">
		<choose-tabs IsFontView :list="tabsList" :checkIndex="tabIndex" @checkView="handleTabs"/>
		<template v-if="tabIndex == 0">
			<view class="margin-top50">
				<avater-item :list="userList"></avater-item>
			</view>
		</template>
		<template v-else>
			<view class="margin-top50">
				<avater-item :list="userList"></avater-item>
			</view>
		</template>
		<view v-if="userList&&userList.length<1" style="margin-top: 200rpx;">
			<u-empty color="#ffffff" icon-color="#ffffff" text="暂无团队" mode="list"></u-empty>
		</view>
	</view>
</template>

<script>
	import chooseTabs from "@/components/tabs/chooseTabs.vue"
	import listItem from "@/components/list/list-item.vue"
	import avaterItem from "@/components/list/avater-item.vue"
	export default{
		components:{
			chooseTabs,
			listItem,
			avaterItem
		},
		data(){
			return{
				tabIndex:0,
				tabsList:[
					{name:'一级'},
					{name:'二级'}
				],
				userList:[],
				type:1
			}
		},
		onShow() {
			this.getMyteam()
		},
		methods:{
			getMyteam(){
				this.$http.post(this.$api.myTeam,{type:this.type},{token:true}).then(res=>{
					if(res.code == 1){
						this.userList = res.data.map(item=>{
							return {
								id:item.id,
								avatar: item.avatar,
								real_name:item.real_name,
								mobile:item.mobile,
								product_id:item.act_status
							}
						})
					}
				})
			},
			handleTabs(index){
				this.tabIndex = index
				this.type = this.tabIndex + 1
				this.getMyteam()
			},
		}
	}
</script>

<style lang="scss">
	
</style>